package com.franklin.java.configuration.sql.run;

import com.franklin.java.api.state.BaseProjectPersistentState;
import com.franklin.java.entity.sql.JdbcConsoleType;
import com.franklin.java.utils.ProjectUtils;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.Project;

/**
 * @author Franklin
 * @since 2021/9/26 17:16
 */
@State(name = "com.franklin.java.configuration.sql.run.JdbcConsoleState",
    storages = {@Storage(StoragePathMacros.WORKSPACE_FILE)})
public class JdbcConsoleState extends BaseProjectPersistentState<JdbcConsoleState> {

    public String console = JdbcConsoleType.getDefault().getName();

    public JdbcConsoleState(Project myProject) {
        super(myProject);
    }

    public JdbcConsoleState() {
    }

    public static JdbcConsoleState getInstance(Project project){
        return ServiceManager.getService(project,JdbcConsoleState.class);
    }

    public static String getConsole(Project project){
        return getInstance(project).console;
    }
}
